package com.ciban.smarthome.module.ui;

import com.ciban.smarthome.R;
import com.ciban.smarthome.module.ui.base.BaseFragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class SettingFragment extends BaseFragment implements OnClickListener {
	private LinearLayout ll_host, ll_backup, ll_recover, ll_setpwd;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_setting, null);
		initView(view);
		initViewData();
		return view;
	}

	private void initViewData() {

	}

	private void initView(View view) {
		((TextView) view.findViewById(R.id.title)).setText(R.string.setting);
		ll_host = (LinearLayout) view.findViewById(R.id.setting_myhost);
		ll_backup = (LinearLayout) view.findViewById(R.id.setting_backup);
		ll_recover = (LinearLayout) view.findViewById(R.id.setting_recover);
		ll_setpwd = (LinearLayout) view.findViewById(R.id.setting_setpwd);

		setListeners();
	}

	private void setListeners() {
		ll_host.setOnClickListener(this);
		ll_backup.setOnClickListener(this);
		ll_recover.setOnClickListener(this);
		ll_setpwd.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.setting_myhost:
			intent = new Intent(getActivity(), HostActivity.class);
			startActivity(intent);
			break;
		case R.id.setting_backup:
			Toast.makeText(getActivity(), "功能暂时预留", 1).show();
			break;
		case R.id.setting_recover:
			Toast.makeText(getActivity(), "功能暂时预留", 1).show();
			break;
		case R.id.setting_setpwd:
			intent = new Intent(getActivity(), PwdActivity.class);
			startActivity(intent);
			break;
		}
	}
}
